<?php

namespace Admin\Controller;

use Think\Controller;

/**
 * 管理员登陆控制器
 */
class LoginController extends Controller {

 public function login()
    {
    	$this->display();
    }
    public function loginup()
    {
    	 // dump($_POST);
       if (IS_POST) {
       		if (empty($_POST)) {
       			$this->error('您还什么都没有填');
       			exit;
       		}
       		$name = $_POST['name'];
       		$pwd = $_POST['pwd'];

       		$list = M('user')->where(array('user'=>$name))->select();
       		// dump($list);
       		// exit;
       		$user = $list[0]['user'];
       		$pwdd = $list[0]['password'];
       		$id = $list[0]['id'];
       		 if ($name == $user && $pwd == $pwdd) {
                 $_SESSION['user'] = $name;
                 $_SESSION['uid'] = $id;

                $this->success('登入成功',U('Index/index'));
            }else{
                $this->error('登入失败');

               }


       }else{
       	$this->error('请求失败!!!');
       }
    }






    public function logout(){
    	unset($_SESSION['home']);

    	$this->success('成功退出!!',U('Home/Index/index'));
    }
	

}
